home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <iostream.h>
- #include <stdlib.h>
- #include <fstream.h>
- #include <iomanip.h>
- #include <conio.h>
- #include "table.h"
- #include "record.h"
-
-
- struct AFILE // Structure to hold fields
- { // From Ascii.txt
- char name[21];
- char address[31];
- char city[11];
- char state[11];
- char zip[7];
- };
-
-
- AFILE afile;
-
-
- main()
- {
- int stat;
- Record record("ascii.fld"); // Record Object Passing .fld file
-
- Table table("ascii.txt", &record); // Table Object passing ascii file
- // name, and pointer to record
- // object
-
- int index = record.getFieldNum("NAME"); // Init. index field
- int si = table.openIndex(&index,1); // openIndex passing pointer
- // to field, and how many fields
-
-
- clrscr();
-
- //** For Loop to read through the records...
- //** Pass 'si' handle for sorted ordering, nothing for non sorted...
- for (stat = table.gotoFirst(si); stat==TBL_OK; stat = table.gotoNext(si))
- {
- table.Get(); // Get Record into Buffer
-
- record.getField("NAME", afile.name); // Read Fields into
- record.getField("ADDRESS", afile.address); // struct... or lone
- record.getField("CITY", afile.city); // variables, doesn't
- record.getField("STATE", afile.state); // matter!
- record.getField("ZIP", afile.zip);
-
- printf("Name : %s\n", afile.name); // Print Contents!
- printf("Address : %s\n", afile.address);
- printf("City : %s\n", afile.city);
- printf("State : %s\n", afile.state);
- printf("Zip : %s\n", afile.zip);
- printf("______________________________\n\n");
- }
-
- table.gotoFirst(si); // Go back to first record... for example sake...
-
- return 0;
- }
-
-